import java.util.InputMismatchException;
import java.util.Scanner;

public class Player extends Role {

    @Override
    public void generate() {
        Scanner scan = new Scanner(System.in);
        System.out.println("请猜拳：0是石头，1是布，2是剪刀");

        while (true) {
            try {
                int playerNumber = scan.nextInt();
                if (playerNumber >= 0 && playerNumber <= 2) {
                    this.setNumber(playerNumber);
//                    if (playerNumber == 0) {
//                        System.out.println("你出的是: " + playerNumber + " 石头");
//                    } else if (playerNumber == 1) {
//                        System.out.println("你出的是: " + playerNumber + " 布");
//                    } else if (playerNumber == 2) {
//                        System.out.println("你出的是: " + playerNumber + " 剪刀");
//                    }
                    break;
                } else {
                    System.out.println("请不要输入别的数字！请重新选择0、1、2：");
                }
            } catch (InputMismatchException e) {
                System.out.println("请不要输入0、1、2以外的字符！请重新选择0、1、2");
                scan.next();
            } catch (Exception e) {
                System.out.println("捕获异常");
            }
        }

    }
}

